package it.polimi.swKnights.SWIMv2.servlets.messages;

import it.polimi.swKnights.SWIMv2.servlets.SwimServlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class SendMessageController
 */
public class ShowTypeMessage extends SwimServlet
{
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException
	{

		HttpSession session = request.getSession();

		if (session.getAttribute("userName") != null)
		{
			// logged
			request.setAttribute("guest", true);
		}
		else
		{
			// guest
			request.setAttribute("guest", false);
		}

		if (request.getParameter("message") != null)
		{
			request.setAttribute("message", "The message has been sent");
		}
		
		
		request.getRequestDispatcher("WEB-INF/messages/TypeMessages.jsp")
				.forward(request, response);

	}

}
